home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
version
/
vbver32
/
vbver32.frm
< prev
next >
Wrap
Text File
|
1995-11-06
|
18KB
|
534 lines
VERSION 4.00
Begin VB.Form frmVBVer
BorderStyle = 3 'Fixed Dialog
Caption = "Information"
ClientHeight = 4935
ClientLeft = 1305
ClientTop = 1650
ClientWidth = 4530
Height = 5340
HelpContextID = 10
Left = 1245
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4935
ScaleWidth = 4530
ShowInTaskbar = 0 'False
Top = 1305
Width = 4650
Begin VB.Frame Frame1
Caption = "Disk Drives"
Height = 1815
Left = 60
TabIndex = 16
Top = 2760
Width = 4395
Begin VB.ComboBox Combo1
Height = 315
HelpContextID = 30
Left = 1080
Style = 2 'Dropdown List
TabIndex = 17
Top = 240
WhatsThisHelpID = 30
Width = 2295
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Bytes Free:"
Height = 255
Index = 8
Left = 120
TabIndex = 27
Top = 1440
Width = 1635
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Height = 195
Index = 13
Left = 1740
TabIndex = 26
Top = 1440
Width = 1320
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Sectors Per Cluster:"
Height = 255
Index = 9
Left = 120
TabIndex = 25
Top = 1200
Width = 1635
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Height = 195
Index = 12
Left = 1740
TabIndex = 24
Top = 1200
Width = 1320
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Bytes Per Sector:"
Height = 255
Index = 10
Left = 120
TabIndex = 23
Top = 960
Width = 1635
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Total Space:"
Height = 255
Index = 11
Left = 120
TabIndex = 22
Top = 720
Width = 1635
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Height = 195
Index = 11
Left = 1740
TabIndex = 21
Top = 960
Width = 1320
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Height = 195
Index = 10
Left = 1740
TabIndex = 20
Top = 720
Width = 1320
End
Begin VB.Label Label3
Height = 195
Index = 0
Left = 3180
TabIndex = 19
Top = 720
Width = 975
End
Begin VB.Label Label3
Height = 195
Index = 1
Left = 3180
TabIndex = 18
Top = 1440
Width = 975
End
End
Begin VB.Label Label4
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "Copyright ⌐ 1995, David Warren (CIS: 72500,1406)"
ForeColor = &H00000000&
Height = 255
Index = 1
Left = 100
TabIndex = 33
Top = 4660
Width = 4275
End
Begin VB.Label Label4
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "Copyright ⌐ 1995, David Warren (CIS: 72500,1406)"
ForeColor = &H00FFFFFF&
Height = 255
Index = 0
Left = 120
TabIndex = 32
Top = 4680
Width = 4275
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Number of Processors:"
Height = 255
Index = 13
Left = 180
TabIndex = 31
Top = 2340
Width = 1635
End
Begin VB.Label Label2
Height = 195
Index = 9
Left = 1920
TabIndex = 30
Top = 2340
Width = 2175
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Processor Type:"
Height = 255
Index = 12
Left = 180
TabIndex = 29
Top = 2100
Width = 1635
End
Begin VB.Label Label2
Height = 195
Index = 8
Left = 1920
TabIndex = 28
Top = 2100
Width = 2175
End
Begin VB.Label Label2
Height = 195
Index = 7
Left = 1920
TabIndex = 15
Top = 1860
Width = 2175
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Temp Directory:"
Height = 255
Index = 7
Left = 180
TabIndex = 14
Top = 1860
Width = 1635
End
Begin VB.Label Label2
Height = 195
Index = 6
Left = 1920
TabIndex = 13
Top = 1620
Width = 2175
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "System Directory:"
Height = 255
Index = 6
Left = 180
TabIndex = 12
Top = 1620
Width = 1635
End
Begin VB.Label Label2
Height = 195
Index = 5
Left = 1920
TabIndex = 11
Top = 1380
Width = 2175
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Windows Directory:"
Height = 255
Index = 5
Left = 180
TabIndex = 10
Top = 1380
Width = 1635
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Current User:"
Height = 255
Index = 4
Left = 180
TabIndex = 9
Top = 1140
Width = 1635
End
Begin VB.Label Label2
Height = 195
Index = 4
Left = 1920
TabIndex = 8
Top = 1140
Width = 2175
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Computer Name:"
Height = 255
Index = 3
Left = 180
TabIndex = 7
Top = 900
Width = 1635
End
Begin VB.Label Label2
Height = 195
Index = 3
Left = 1920
TabIndex = 6
Top = 900
Width = 2175
End
Begin VB.Label Label2
Height = 195
Index = 2
Left = 1920
TabIndex = 5
Top = 660
Width = 2175
End
Begin VB.Label Label2
Height = 195
Index = 1
Left = 1920
TabIndex = 4
Top = 420
Width = 2175
End
Begin VB.Label Label2
Height = 195
Index = 0
Left = 1920
TabIndex = 3
Top = 180
Width = 2175
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Build Number:"
Height = 255
Index = 2
Left = 180
TabIndex = 2
Top = 660
Width = 1635
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Version:"
Height = 255
Index = 1
Left = 180
TabIndex = 1
Top = 420
Width = 1635
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Operating System:"
Height = 255
Index = 0
Left = 180
TabIndex = 0
Top = 180
Width = 1635
End
End
Attribute VB_Name = "frmVBVer"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
'************************************************
'VBVer32
'Sample of System Information functions available
'in the Win32 API.
'By David Warren
'MMC SoftwareÖ
'CompuServe: 72500,1406
'davidw@mmcsoftware.com
'**********************
'vbVer32
'
Private Sub Combo1_Click()
On Error GoTo Combo1_Click_Error
Dim lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long
Dim sRoot As String, lResult As Long, lTotal As Long, lFree As Long
lpSectorsPerCluster = 0
lpBytesPerSector = 0
lpNumberOfFreeClusters = 0
lpTotalNumberOfClusters = 0
sRoot = Left$(Combo1.Text, 3)
lResult = GetDiskFreeSpace(sRoot, lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters)
lTotal = lpSectorsPerCluster * lpBytesPerSector * lpTotalNumberOfClusters
lFree = lpSectorsPerCluster * lpBytesPerSector * lpNumberOfFreeClusters
If lTotal = 0 Then
'either removable - no disk in drive, or
'ghosted network drive, server not available
Label2(10).Caption = "Not available"
Label3(0).Caption = ""
Label2(11).Caption = ""
Label2(12).Caption = ""
Label2(13).Caption = ""
Label3(1).Caption = ""
Else
Label3(1).Caption = "(" & Format$(lFree / (1024& * 1024&), "###,###.##") & " MB)"
Label2(10).Caption = Format$(lTotal, "###,###,###,###")
Label3(0).Caption = "(" & Format$(lTotal / (1024& * 1024&), "###,###.##") & " MB)"
Label2(11).Caption = Format$(lpBytesPerSector, "###,###,###,###")
Label2(12).Caption = Format$(lpSectorsPerCluster, "###,###,###,###")
Label2(13).Caption = Format$(lFree, "###,###,###,##0")
Label3(1).Caption = "(" & Format$(lFree / (1024& * 1024&), "###,##0.##") & " MB)"
End If
Combo1_Click_Exit:
Exit Sub
Combo1_Click_Error:
MsgBox "Error " & Format$(Err) & ": " & Error$ & " in Combo1_Click"
Resume Combo1_Click_Exit
End Sub
Private Sub Form_Load()
On Error GoTo Form_Load_Error
Dim OSVer As OSVERSIONINFO, lResult As Long, sComputerName As String, sUsername As String
Dim lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long
Dim lTotal As Long, lFree As Long
Dim sBuffer As String, sDrives As String, sDriveID As String
Dim SysInfo As SYSTEM_INFO
If InStr(UCase$(Command$), "DEBUG") Then gfDEBUG = True
'Center the form on the desktop
'The conventional method is:
'Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
'however, to take into consideration the position of the
'TaskBar in Windows 95, do the following:
Dim lpRect As RECT, hTaskBar As Long, lWidth As Long, lHeight As Long
hTaskBar = FindWindow("Shell_TrayWnd", 0&)
If hTaskBar > 0 Then
lResult = GetWindowRect(hTaskBar, lpRect)
End If
If (lpRect.Right - lpRect.Left) > (lpRect.Bottom - lpRect.Top) Then
'it's on top or bottom
lWidth = (Screen.Width - Me.Width) \ 2
lHeight = (Screen.Height - Me.Height) \ 2
If lpRect.Top <= 0 Then
lHeight = lHeight + ((lpRect.Bottom * Screen.TwipsPerPixelY) \ 2)
Else
lHeight = lHeight - ((lpRect.Bottom - lpRect.Top) * Screen.TwipsPerPixelY) \ 2
End If
Else
'it's on left or right
lHeight = (Screen.Height - Me.Height) \ 2
lWidth = (Screen.Width - Me.Width) \ 2
If lpRect.Left = 0 Then
lWidth = lWidth + ((lpRect.Right * Screen.TwipsPerPixelX) \ 2)
Else
lWidth = lWidth - ((lpRect.Right - lpRect.Left) * Screen.TwipsPerPixelX) \ 2
End If
End If
Me.Move lWidth, lHeight
'*** End Form Centering Code
If InStr(UCase$(Command$), "DEBUG") Then gfDEBUG = True
OSVer.dwOSVersionInfoSize = Len(OSVer)
lResult = GetVersionEx(OSVer)
If lResult Then
Select Case OSVer.dwPlatformId
Case VER_PLATFORM_WIN32s
'NOTE: VB4/32 apps won't run on Win32s
Label2(0).Caption = "Win32s Subsystem on Windows 3.x"
Case VER_PLATFORM_WIN32_WINDOWS
Label2(0).Caption = "Microsoft Windows 95"
'NOTE: This value will applies for all 32-bit non-NT Windows versions,
'not necessarily just Windows 95
Case VER_PLATFORM_WIN32_NT
Label2(0).Caption = "Microsoft Windows NT"
End Select
End If
Label2(1).Caption = Format$(OSVer.dwMajorVersion) & "." & Format$(OSVer.dwMinorVersion, "00")
Label2(2).Caption = Format$(OSVer.dwBuildNumber Mod 65536)
'Get Names APIs:
sComputerName = String$(32, 0)
lResult = GetComputerName(sComputerName, Len(sComputerName))
If lResult Then
Label2(3).Caption = sComputerName
End If
sUsername = String$(32, 0)
lResult = GetUserName(sUsername, Len(sUsername))
If lResult Then
Label2(4).Caption = sUsername
End If
'Get Directories APIs:
sBuffer = String$(255, 0)
lResult = GetWindowsDirectory(sBuffer, Len(sBuffer))
If lResult > 0 Then Label2(5).Caption = sBuffer
sBuffer = String$(255, 0)
lResult = GetSystemDirectory(sBuffer, Len(sBuffer))
If lResult > 0 Then Label2(6).Caption = sBuffer
sBuffer = String$(255, 0)
lResult = GetTempPath(Len(sBuffer), sBuffer)
If lResult > 0 Then Label2(7).Caption = sBuffer
' NOTE that the string returned by this function
' has the trailing '\' unlike all other path functions
'GetSystemInfo
Call GetSystemInfo(SysInfo)
Label2(8).Caption = Format$(SysInfo.dwProcessorType)
Label2(9).Caption = Format$(SysInfo.dwNumberOfProcessors)
'Drive Information
sDrives = String$(128, 0) 'four characters * 26 + extra Null = 105
'Cool! returns a string: A:\(NULL)B:\(NULL)C:\(NULL)...
lResult = GetLogicalDriveStrings(1024, sDrives)
Do While Left$(sDrives, 1) <> Chr$(0)
'pull one off the front
sDriveID = UCase$(Left$(sDrives, 3))
sDrives = Mid$(sDrives, 5)
'what kind is it?
lDrive = GetDriveType(sDriveID)
Select Case lDrive
Case DRIVE_REMOVABLE
Combo1.AddItem sDriveID & " [removable]"
Case DRIVE_FIXED
Combo1.AddItem sDriveID & " [fixed disk]"
Case DRIVE_REMOTE
'get its UNC name
sBuffer = String$(255, 0)
'don't forget to drop the "\" from the ID for this call
lResult = WNetGetConnection(Left$(sDriveID, 2), sBuffer, Len(sBuffer))
If lResult = 0 Then
Combo1.AddItem sDriveID & " " & sBuffer
End If
Case DRIVE_CDROM
Combo1.AddItem sDriveID & " [CD-ROM]"
Case DRIVE_RAMDISK
Combo1.AddItem sDriveID & " [ramdisk]"
End Select
'Select the drive containing the Windows directory
If Left$(Combo1.List(Combo1.ListCount - 1), 2) = Left$(Label2(5).Caption, 2) Then
Combo1.ListIndex = Combo1.ListCount - 1 ' will activate Combo1_Click
End If
Loop
Form_Load_Exit:
Exit Sub
Form_Load_Error:
MsgBox "Error " & Format$(Err) & ": " & Error$ & " in Form_Load"
If gfDEBUG Then
Stop
Resume Next 'lets us step to the line following the error
Else
Resume Form_Load_Exit
End If
End Sub